<template>
  <div>
    <el-container>
      <el-header><Header1></Header1></el-header>
      <el-main>

        <div id="title">模型上传</div>

        <div>
          <el-steps :active="1" align-center>
            <el-step title="步骤1" description="提交模型相关信息"></el-step>
            <el-step title="步骤2" description="提交模型使用规范"></el-step>
            <el-step title="步骤3" description="提交模型运行方式"></el-step>
            <el-step title="步骤4" description="提交模型测试用例"></el-step>
          </el-steps>
        </div>

        <el-form ref="modelform" 
          :model="modelform"
          :rules="rules" >
          <el-row type="flex" justify="center">
            <el-col :span="4">
              <el-form-item prop="modelname">
                <el-input v-model="modelform.modelname" placeholder="输入模型名称"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="4">
              <el-form-item prop="patentnum">
                <el-input v-model="modelform.patentnum"  placeholder="输入专利号"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="4">
              <el-form-item prop="language">
                <el-input v-model="modelform.language"  placeholder="输入模型开发语言"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex" justify="center">
            <el-col :span="4">
              <el-form-item prop="developername">
                <el-input v-model="modelform.developername" disabled  placeholder="输入开发单位/个人"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <!--
          <el-row type="flex" justify="center">
            <el-col :span="4">
              <el-form-item>
                <el-input
                  type="textarea"
                  :rows="4"
                  resize="none"
                  placeholder="输入数据"
                  v-model="modelform.textarea2">
                </el-input>
              </el-form-item>
            </el-col>
          </el-row>
-->
          <el-row type="flex" justify="center">
            <el-col :span="2">
              <el-form-item>
                <el-button round @click="home">返回</el-button>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-form-item>
                <el-button round disabled>提交</el-button>
              </el-form-item>
            </el-col>
            <el-col :span="2">
              <el-form-item>
                <el-button round @click="submitForm('modelform')">下一步</el-button>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>

      </el-main>
      <el-footer height="120px"><Footer></Footer></el-footer>
    </el-container>
  </div>
</template>

<script>

// @ is an alias to /src
import Header1 from "@/components/Header1";
import Footer from "@/components/Footer";


export default {
  name: "upload1",
  mounted(){
    this.modelform.developername=JSON.parse(this.$store.state.UserMessage).uName
    console.log()
  },
  components: { Footer,Header1},
  data() {
    
    return {
      items:[
        Header1
      ],
      modelform: {
        modelname: '',
        patentnum: '',
        language: '',
        developername:'',
      },
      rules: {
        modelname: [{ required: true, message: '请输入模型名称', trigger: 'blur'}],
        language: [{ required: true, message: '请输入开发语言种类', trigger: 'blur' }],
        developername: [{ required: true, message: '请输入开发者名称', trigger: 'blur' }],
      }
    }
  },
  methods:{
   
    home(){
      this.$router.push("/")
    },
    submitForm(formName) {

      let fd = new FormData();
      fd.append("model_name",this.modelform.modelname);
      fd.append("patent_num",this.modelform.patentnum);
      fd.append("language",this.modelform.language);
      fd.append("developer",this.modelform.developername);

      let config = {
        headers: {
          'Content-Type': 'multipart/form-data'
        }
      }
      this.$refs[formName].validate(valid => {
        if(valid){
          this.$axios.post("user/login/register", fd, config).then(res => {
            alert(res.data.msg)
            if(res.data.msg === "下一步")
            {
              console.log(res.data)
              this.$router.push({path:'/upload2'})
            }
          }).catch(res => {
              alert(res.data.msg)
          })
        }else{
          alert("请检查输入信息!")
        }
      })
    },
  }
}
</script>

<style scoped>
/deep/ .el-step__head.is-finish {
  color: #3A62D7;
  border-color: #3A62D7;
}
/deep/ .el-step__title.is-finish {
  color: #3A62D7;
}
/deep/ .el-step__description.is-finish {
  color: #3A62D7;
}



/deep/ .el-input__inner { /*或者 .s2>>>.el-input__inner  */

  border-radius: 20px; /*输入框圆角值*/
  background-color: #ffffff;
  /*background: transparent;*/
}

.el-button {
  background: #3A62D7;
  border: #3A62D7;
  color: #F5F5F5;
}
.el-row {
  margin-top: 30px;
  margin-bottom: 20px;
}

#title {
  color: #333333;
  font-size: 30px;
  font-weight: bold;
  border: #333333;
  margin-top: 50px;
  margin-bottom: 20px;
}

.el-header{
  background-color: #F5F5F5;
  color: #333;
  text-align: center;
  line-height: 60px;
}
.el-footer {
  background-color: #F5F5F5;
  color: #333;
  text-align: center;
  line-height: 3px;

}

.el-aside {
  background-color: #D3DCE6;
  color: #333;
  text-align: center;
  line-height: 150px;
}

.el-main {
  background-color: #F5F5F5;
  background-size: 100% 100%;
  /*background-color: #E9EEF3;*/
  color: #333;
  text-align: center;
  height: 800px;
  padding: unset;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
</style>